<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class loginComponents extends sfComponents {

    public function executeMenu() {
        $this->caps = $this->getUser()->getAttribute('caps');
    }
    
    public function executeMenuUser() {
        $this->caps = $this->getUser()->getAttribute('caps');
        $this->nombre = $this->getUser()->getAttribute('nombre');
    }
    
    public function executeStores() {
        $user = $this->getUser()->getAttribute('id_users');

        /** Stores * */
        $q = Doctrine_Query::create()
                ->from('Stores s')
                ->innerJoin('s.UserStores us')
                ->where('us.id_users = ?', array($user))
                ->orderBy('s.name');

        $this->stores = $q->fetchArray();
    }
    
    public function executeStoresName() {

        $id = $_GET['id'];
        /** Stores * */
        $q = Doctrine_Query::create()
                ->from('Stores s')
                ->where('s.id_store = ?', array($id))
                ->orderBy('s.name');
        $storeName = $q->fetchArray();

        $this->storesName = $storeName[0]['name'];
    }

}

?>
